// eslint-disable-next-line vue/multi-word-component-names
import { ref } from 'vue';
import AddVCutToolRecord from '../../modal/add-v-cut-tool-record.vue';
import SearchKnifeInfo from '../../modal/search-knife-info.vue';

const visible = ref(false);
const currentRow = ref(null);
const modalOperateType = ref('add');

const searchVisible = ref(false);

export default {
  url: '/qms/single/singleVcutKnifes/selectDataList',
  delUrl: '/qms/single/singleVcutKnifes/deleteData',
  // 导出
  downLoadUrl: 'qms/single/singleVcutKnifes/exportExcel',
  searchFormList: [
    {
      type: 'select',
      key: 'knifeLib',
      label: '刀组查询',
      placeholder: '请选择需要查询的刀组',
      span: 8,
      md: 12,
      lg: 8,
      xl: 8,
      xxl: 4,
      selectOptions: [
        {
          value: 'A',
          label: 'A'
        },
        {
          value: 'B',
          label: 'B'
        },
        {
          value: 'C',
          label: 'C'
        },
        {
          value: 'D',
          label: 'D'
        },
        {
          value: 'E',
          label: 'E'
        },
        {
          value: 'F',
          label: 'F'
        }
      ]
    },
    {
      type: 'input',
      key: 'serialNum',
      label: '单据号',
      placeholder: '请输入单据号',
      span: 24,
      md: 12,
      lg: 8,
      xl: 8,
      xxl: 4
    },
    {
      type: 'select',
      key: 'state',
      label: '审核状态',
      placeholder: '请选择审核状态',
      span: 6,
      md: 12,
      lg: 8,
      xl: 8,
      xxl: 4,
      selectOptions: [
        {
          value: '0',
          label: '待领班审核'
        },
        {
          value: '1',
          label: '待修改'
        },
        {
          value: '2',
          label: '待主管审核'
        },
        {
          value: '3',
          label: '审核完成'
        }
      ]
    },
    {
      type: 'input',
      key: 'knifeNum1',
      label: '刀具上编号',
      placeholder: '请输入上编号进行查询',
      span: 6,
      md: 12,
      lg: 10,
      xl: 8,
      xxl: 4,
      showTime: true
    },
    {
      type: 'input',
      key: 'knifeNum2',
      label: '刀具下编号',
      placeholder: '请输入上编号进行查询',
      span: 6,
      md: 12,
      lg: 10,
      xl: 8,
      xxl: 4,
      showTime: true
    },
    {
      type: 'dateRangePicker',
      key: 'time',
      label: '时间',
      span: 6,
      md: 12,
      lg: 10,
      xl: 8,
      xxl: 6,
      showTime: true
    }
  ],
  searchParam: ref({
    time: null
  }),
  column: [
    {
      key: 'dataIndex',
      dataIndex: 'dataIndex',
      title: '序号',
      width: 70,
      fixed: 'left',
      align: 'center',
      checked: true
    },
    {
      key: 'serialNum',
      dataIndex: 'serialNum',
      title: '单据号',
      width: 130,
      align: 'center',
      fixed: 'left',
      checked: true,
      ellipsis: true
    },
    {
      key: 'useDate',
      dataIndex: 'useDate',
      title: '使用日期',
      width: 130,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'state',
      dataIndex: 'state',
      title: '审核状态',
      width: 110,
      align: 'center',
      checked: true,
      ellipsis: true,
      customRender: ({ record }) => {
        return ['待领班审核', '待修改', '待主管审核', '审核完毕'][record.state];
      }
    },
    {
      key: 'knifeLib',
      dataIndex: 'knifeLib',
      title: '刀具库',
      width: 80,
      align: 'center',
      checked: true,
      ellipsis: true
    },

    {
      key: 'knifeNum1',
      dataIndex: 'knifeNum1',
      title: '刀具上编号',
      width: 125,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'knifeNum2',
      dataIndex: 'knifeNum2',
      title: '刀具下编号',
      width: 125,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'knifeDiameter1',
      dataIndex: 'knifeDiameter1',
      title: '刀具直径1',
      width: 90,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'knifeDiameter2',
      dataIndex: 'knifeDiameter2',
      title: '刀具直径2',
      width: 90,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'useDateTotalLength',
      dataIndex: 'useDateTotalLength',
      title: '累计行程(m)',
      width: 120,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'useDateLength',
      dataIndex: 'useDateLength',
      title: '当日实际行程(m)',
      width: 130,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'grind',
      dataIndex: 'grind',
      title: '研磨',
      width: 100,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'operator',
      dataIndex: 'operator',
      title: '记录人',
      width: 100,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'foreman',
      dataIndex: 'foreman',
      title: '领班审核',
      width: 80,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'foremanTime',
      dataIndex: 'foremanTime',
      title: '领班审核时间',
      width: 150,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'examiner',
      dataIndex: 'examiner',
      title: '主管审核',
      width: 80,
      align: 'center',
      checked: true,
      ellipsis: true
    },

    {
      key: 'examinerTime',
      dataIndex: 'examinerTime',
      title: '主管审核时间',
      width: 150,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'remark',
      dataIndex: 'remark',
      title: '备注',
      width: 180,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'createDate',
      dataIndex: 'createDate',
      title: '创建时间',
      width: 180,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'createBy',
      dataIndex: 'createBy',
      title: '创建人',
      width: 100,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'updateDate',
      dataIndex: 'updateDate',
      title: '修改时间',
      width: 180,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'updateBy',
      dataIndex: 'updateBy',
      title: '修改人',
      width: 100,
      align: 'center',
      checked: true,
      ellipsis: true
    }
  ],
  isCustomAdd: true,
  rednderComponents: [
    () => {
      return (
        <AddVCutToolRecord
          visible={visible.value}
          rowData={currentRow.value}
          operateType={modalOperateType.value}
          onAddModalClose={() => (visible.value = false)}
          onAddSuccess={() => {}}
        ></AddVCutToolRecord>
      );
    },
    () => (
      <SearchKnifeInfo visible={searchVisible.value} onClose={() => (searchVisible.value = false)}></SearchKnifeInfo>
    )
  ],
  openModal(val) {
    console.log('val', val);

    visible.value = true;
    currentRow.value = val.currentRow;
    modalOperateType.value = val.operateType;
  },
  otherBtnList: [
    {
      icon: 'icon-chakanbiaozhun',
      name: '查询刀具库',
      iconType: 3,
      auth: 'production-management:203:search-knife-info',
      handleClick() {
        searchVisible.value = true;
      }
    }
  ],
  // 列表创建人不显示
  isProductionTable: false,
  // 导出按钮是否显示
  showDownload: true,
  scroll: { y: 'auto' },
  modalClose() {
    moduleNoSearchData.value = null;
  }
};
